package cn.netswap.jeegorilla.framework.security.strategy;

import org.springframework.security.web.session.SessionInformationExpiredEvent;
import org.springframework.security.web.session.SessionInformationExpiredStrategy;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by lai_gw on 2020/3/29.
 *
 */
public class GorillaExpiredSessionStrategy implements SessionInformationExpiredStrategy {

    /**
     * 在此可以直接 设置标识让前端去跳转到并发登录 的警示界面
     * @param event
     * @throws IOException
     * @throws ServletException
     */
    @Override
    public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
        HttpServletResponse response = event.getResponse();
        response.setContentType("application/json;charset=UTF-8");
        response.getWriter().write("并发登录");
    }
}
